<template>
	<view>
		<app-header color="#fff" :title="headerTitle" />
		<view class="goodsInfoTabList comm-container">
			<view class="wraper">
				<view class="title">
					物品类型
				</view>
				<view class="box">
					<view class="info-item" @click="tabLabel(item,index)"  :class="active == index ? 'active': ''" v-for="(item,index) in tabList" :key="index">
						<text>{{item.dictLabel}}</text>
					</view>
				</view>
			</view>
		</view>
		<view style="padding: 0 20rpx;">
			<view class="card-wraper">
				<view class="card-item">
					<view class="text">总重量(kg)</view>
					<view class="val">
						<uni-number-box v-model="query.weight" min="0.5" step="0.5" integer="digit" class="countNumberBg" />
					</view>
				</view>
				<view class="card-item">
					<view class="text">数量</view>
					<view class="val">
						<uni-number-box v-model="query.num" min="0.5" step="0.5" integer="digit" class="countNumberBg" />
					</view>
				</view>
			</view>
		</view>
		<view class="footer-btn">
			<u-button
			  @click="SignClick"
			  type="success"
			  shape="circle"
			  text="保存"
			  style="width: 100%;"
			  color="#2979FF"
			></u-button>
		</view>
	</view>
</template>

<script>
	import AppHeader from "@/subpages/components/header.vue"
	import { getDictData } from "@/api/logistics.js"
	export default {
		components: {
			AppHeader
		},
		data() {
			return {
				active: 0,
				headerTitle: "物品信息",
				tabList: [],
				query: {
					num: 1,
					weight: "1.0",
					cargo: "生活用品"
				}
			}
		},
		mounted() {
			this.getData();
		},
		methods: {
			async getData() {
				const data = await getDictData("wl_wp_type");
				this.tabList = data.data;
			},
			tabLabel(item,index) {
				this.active = index;
				this.query.cargo = item.dictLabel;
			},
			SignClick() {
				const eventChannel = this.getOpenerEventChannel();
				eventChannel.emit('Selected',this.query);
				uni.navigateBack();
			}
		}
	}
</script>

<style lang="scss" scoped>
	.goodsInfoTabList {
		.wraper {
			background: #fff;
			border-radius: 20rpx;
			padding: 40rpx 20rpx;
			.title {
				font-size: 34rpx;
				padding-bottom: 20rpx;
				border-bottom: 1px solid #D3D3D3;
			}
			.box {
				display: flex;
				justify-content: space-between;
				flex-wrap: wrap;
				.info-item {
					width: 31.333%;
					text-align: center;
					background: #F5F5F5;
					border-radius: 40rpx;
					padding: 10rpx 0;
					margin-top: 40rpx;
					border: 1px solid transparent;
					&.active {
						border-color: #2979FF;
						color: #2979FF;
						background-color: #fff;
					}
				}
			}
		}	
	}
	.card-item {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 30rpx;
		border-bottom: 1px solid #D3D3D3;
		padding-bottom: 30rpx;
		&:nth-child(2) {
			margin-bottom: 0;
			border: 0;
			padding-bottom: 0;
		}
		.text {
			font-size: 32rpx;
		}
	}
	.countNumberBg {
		::v-deep .uni-numbox  {
			background: #fff !important;
			border: 1px solid #E6E6E6 !important;
			border-radius: 40rpx !important;
			overflow: hidden !important;
		}
		::v-deep .uni-numbox-btns {
			background: #fff !important;
			padding: 0 30rpx !important;
		}
		::v-deep .uni-numbox__value {
			background: transparent !important;
			height: 70rpx;
		}
		::v-deep .uni-numbox--text {
			font-size: 45rpx !important;
		}
	}
	.footer-btn {
		background: #fff;
		padding: 20rpx;
		position: fixed;
		bottom: 0;
		left: 0;
		box-sizing: border-box;
		width: 100%;
	}
</style>